package com.richard.base.ui

import androidx.databinding.DataBindingUtil
import androidx.databinding.ViewDataBinding
import androidx.lifecycle.ViewModel
import com.richard.base.ui.BaseActivity


/**
 * 需要使用ViewModel ，继承这个
 */
abstract class BaseVMActivity<VM : ViewModel>(useBinding: Boolean = false) : BaseActivity() {

    private val _useBinding = useBinding


    override fun setLayoutView() {


        startObserve()
        if (_useBinding) {
            mBinding = DataBindingUtil.setContentView<ViewDataBinding>(this, getLayoutResId())
            mBinding.lifecycleOwner =this
        } else setContentView(getLayoutResId())
    }

    protected lateinit var mBinding: ViewDataBinding
    abstract fun startObserve()

    abstract fun getLayoutResId(): Int


}